import httpInstance from '@/utils/http'

// 获取评论列表
export const getComments = async (pId,current,size) => {
  try {
    const res = await httpInstance.request({
      url: '/api/productComment/'+pId,
      method: 'POST',
      data: {
        current,
        size
      }
    })
    return res
  } catch (error) {
    throw error
  }
}

// 发送评论
export const sendComment = async ({uId,pId,comment,rate}) => {
  try {
    const res = await httpInstance.request({
      url: '/api/productComment',
      method: 'POST',
      data: {
        userId: uId,
        productId: pId,
        comment,
        rate
      }
    })
    return res
  }
  catch (error) {
    throw error
  }
}